package com.wskj.insuranceweb.reporter.mapper;

import com.wskj.insuranceweb.reporter.pojo.Backuparea;
import com.wskj.insuranceweb.reporter.pojo.Document;
import com.wskj.insuranceweb.reporter.pojo.Reporter;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface ReporterMapper {


    List<Reporter> showList(@Param("kname") String kname,@Param("bname") String bname,@Param("start") Long start,@Param("end") Long end);

    //Long getCount(@Param("kname") String kname,@Param("bname") String bname);
    @Insert("insert into reporter values(seq_1.nextval,#{report},#{reportname},to_date(#{reportdate},'yyyy-MM-dd'),#{customernumber}," +
            "#{sex},to_date(#{accidentdate},'yyyy-MM-dd'),#{address},#{accidentid}" +
            ",#{outheaddress},#{phone},#{employeename},#{because},#{claimstatus})")
    void addReporter(Reporter reporter);
    Reporter findReporter(String id);
    @Insert("insert into document values(seq_docu.nextval,#{documentcode},#{documentname},#{documentnumber},#{customernumber})")
    void addDocument(Document document);
    @Update("update reporter set accept = '不予受理' where report = #{0}")
    void updateAccept(String report);
    @Update("update reporter set accept = #{accept} where id = #{id}")
    void updateReporter(@Param("id") String id, @Param("accept") String accept);

    Reporter findReporterById(String id);

    Reporter getReporter(String cust);
    @Update("update reporter set rejection= #{rejection},accept = '不予受理' where customernumber= #{cust}")
    void updateReporterByCust(@Param("cust") String cust,@Param("rejection") String rejection);
    @Update("update reporter set accept = #{accept},rejection = #{rejection} where id = #{id}")
    void updateReporterNo(@Param("id") String id, @Param("accept") String accept,@Param("rejection") String rejection);
    @Insert("insert into backuparea values(#{report},#{reportname},to_date(#{reportdate},'yyyy-MM-dd'),to_date(#{accidentdate},'yyyy-MM-dd')," +
            "#{because},#{address},#{customernumber},sysdate,#{phone})")
    void addBackuparea(Reporter reporter);
    @Select("select * from reporter where report = #{0}")
    Reporter findReporterByReporter(String reporter);
    @Update("update reporter set reportdate = to_date(#{reportdate},'yyyy-MM-dd'),accidentdate =  to_date(#{accidentdate},'yyyy-MM-dd')," +
            "reportname = #{reportname},phone = #{phone},because = #{because},address = #{address} where report = #{report}")
    void update(Backuparea b);
    @Update("update reporter set accept = '不予受理',rejection= #{conclusion} where report = #{report}")
    void edtiReporter(@Param("report") String report, @Param("conclusion") String conclusion);
}
